<?
/**
 * Copyright 2007 Melange.
 *
 * This file is part of PHP-MELANGE.
 *
 * PHP-MELANGE is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * PHP-MELANGE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PHP-MELANGE; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * @category    Melange
 * @package     php-melange
 * @subpackage  cms
 * @copyright   Copyright (c) 2007 Jeroen Simons. All rights reserved
 * @author      Jeroen Simons <jeroen@melange.nl>
 * @link        http://www.melange.nl/
 *
 */

require_once("cms/core/helper/Abstract.php");

class PHP_CMS_View_Helper_Header extends PHP_CMS_View_Helper_Abstract {

    public function header($richtext=false, $newsletter_rich_text=false, $forum_rich_text=false) {

        $request = $this->pageContext->request;

        $base = $request->getScheme()."://" .
                $request->getServerName() .
                ($request->getServerPort() != 80 ? ":".$request->getServerPort() : "") .
                $request->getContextPath() . "/";

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title><?=$this->param(_Core::NAME)?></title>
        <base href="<?=$base?>" />
        
        <link rel="stylesheet" type="text/css" href="screen" media="all"/>
        <script type="text/javascript" src="static.php?file=<?=$this->image("cms/core/view/js/application.js")?>"></script>

        <? if($this->tinymce() !== null && $richtext === true) { ?>
        <script type="text/javascript" src="<?=$this->tinymce()?>tiny_mce.js"></script>

        <script type="text/javascript">
        tinyMCE.init({

        <? if($newsletter_rich_text): ?>

            mode : "specific_textareas",
            theme : "advanced",
            plugins : "advimage,table,autosave",
            theme_advanced_buttons1 : "formatselect,styleselect,separator,fontselect,fontsizeselect,separator,emotions",
            theme_advanced_buttons2 : "hr,separator,bold,italic,underline,strikethrough,separator,undo,redo,separator,link,unlink,separator,cleanup,separator,image,separator,code",
            theme_advanced_buttons3 : "tablecontrols,separator,charmap,removeformat",
            external_image_list_url : "<?=$base?>image/tinymce?newsletter=true",
            convert_urls : false,
            relative_urls : true,
            document_base_url : "<?=$base?>",
            entities : "",
            inline_styles : true,
            content_css : "<?=$base?>css/<?=$newsletter_rich_text ? "newsletter" : "tiny"?>.css",
            extended_valid_elements : "map[name],area[shape|alt|coords|href]",
            theme_advanced_blockformats : "h1,h2,h3"

        <? elseif($forum_rich_text): ?>

            mode : "specific_textareas",
            theme : "advanced",
            plugins : "emotions",
            theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,undo,redo,separator,link,unlink,separator,cleanup,separator,charmap,emotions,removeformat",
            theme_advanced_buttons2 : "",
            theme_advanced_buttons3 : "",
            convert_urls : true,
            relative_urls : true,
            document_base_url : "<?=$base?>",
            entities : "",
            inline_styles : true,
            content_css : "<?=$base?>css/tiny.css",
            extended_valid_elements : "map[name],area[shape|alt|coords|href]",

        <? else: ?>

            mode : "specific_textareas",
            theme : "advanced",
            plugins : "advimage,table,autosave",
            theme_advanced_buttons1 : "formatselect,styleselect,separator,fontselect,fontsizeselect",
            theme_advanced_buttons2 : "bullist,numlist,separator,hr,separator,bold,italic,underline,strikethrough,separator,undo,redo,separator,link,unlink,separator,cleanup,separator,image,separator,code",
            theme_advanced_buttons3 : "tablecontrols,separator,charmap,removeformat",
            external_image_list_url : "<?=$base?>image/tinymce",
            convert_urls : false,
            relative_urls : true,
            document_base_url : "<?=$base?>",
            entities : "",
            inline_styles : true,
            content_css : "<?=$base?>css/tiny.css",
            extended_valid_elements : "map[name],area[shape|alt|coords|href]",
            theme_advanced_blockformats : "h1,h2,h3"

        <? endif; ?>

        });
        </script>

        <? } ?>

        <!--[if lte ie 6]>
        <style type="text/css" media="screen">
            fieldset, .ctrl, .ctrl span, .hint {
              zoom:1;
            }
        </style>
        <![endif]-->

        <!--[if ie]>
        <style type="text/css" media="screen">
            html, body, td, th, form, input, textarea, select, fieldset, button {
                font: 11px Verdana, arial, sans-serif;
            }
            h1 {
                font-size:24px;
            }
        </style>
        <![endif]-->

    </head>
    <body>

        <div id="border">

            <div id="content">


    <? }

}
?>